/*
 * 文件名：CrossingController.java	 
 * 时     间：下午8:14:09
 * 作     者：Administrator       
 * 版     权： 2012-2022 湖南智软网络科技, 公司保留所有权利.
 * 联     系：http://www.073586.com/
 */
package com.local.controller.admin;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.local.entity.vo.StationAndCrossionVo;
import com.local.model.Crossing;
import com.local.model.CrossingToEquipment;
import com.local.model.CrossingToStation;
import com.local.page.CrossingPageInfo;
import com.local.service.face.CrossingService;
import com.qianhai.common.constants.CommonContans;
import com.qianhai.common.controller.BaseController;


/**
 * 类描述:路口管理
 * 
 * @ClassName: CrossingController
 * @author Administrator
 * @date 2015年10月6日 下午8:14:09
 */
@RestController
@RequestMapping(value = "/admin/crossing", method = RequestMethod.POST)
public class CrossingController extends BaseController
{
	@Autowired
	private CrossingService crossingService;
	
	/**
	 * 
	 * 方法描述：
	 * 
	 * @Title: addCrossin
	 * @param @param crossing
	 * @param @return
	 * @return ModelMap
	 * @user Administrator 2015年10月6日
	 * @throws
	 */
	@RequestMapping(value = "/addCrossin.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap addCrossin(@RequestBody Crossing crossing)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			crossingService.addCrossin(crossing);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：
	 * 
	 * @Title: editCrossinById
	 * @param @param crossing
	 * @param @return
	 * @return ModelMap
	 * @user Administrator 2015年10月6日
	 * @throws
	 */
	@RequestMapping(value = "/editCrossinById.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap editCrossinById(@RequestBody Crossing crossing)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			crossingService.editCrossinById(crossing);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：
	 * 
	 * @Title: editCrossinById
	 * @param @param crossing
	 * @param @return
	 * @return ModelMap
	 * @user Administrator 2015年10月6日
	 * @throws
	 */
	@RequestMapping(value = "/getCrossinByid.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap getCrossinByid(String uuid)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			
			resultMap.put(CommonContans.STRUTS_DATA,
					crossingService.getCrossinByid(uuid));
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：
	 * 
	 * @Title: delCrossinById
	 * @param @param uuid
	 * @param @return
	 * @return ModelMap
	 * @user Administrator 2015年10月6日
	 * @throws
	 */
	@RequestMapping(value = "/delCrossinById.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap delCrossinById(String uuid)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			
			crossingService.delCrossinById(uuid);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：
	 * 
	 * @Title: queryCrossinByPage
	 * @param @param page
	 * @param @return
	 * @return ModelMap
	 * @user Administrator 2015年10月6日
	 * @throws
	 */
	@RequestMapping(value = "/queryCrossinByPage.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap queryCrossinByPage(@RequestBody CrossingPageInfo page)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			crossingService.queryCrossinByPage(page);
			
			resultMap.put(CommonContans.STRUTS_DATA, page);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	@RequestMapping(value = "/createVidoConnect.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap createVidoConnect(String uuid)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			crossingService.createVidoConnect(uuid);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	@RequestMapping(value = "/queryCrossinBySationId.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap queryCrossinBySationId(String sationId)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			
			resultMap.put(CommonContans.STRUTS_DATA,
					crossingService.queryCrossinBySationId(sationId));
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	@RequestMapping(value = "/queryEquimentByCrossionId.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap queryEquimentByCrossionId(String crssionId)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			resultMap.put(CommonContans.STRUTS_DATA,
					crossingService.queryEquimentByCrossionId(crssionId));
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	@RequestMapping(value = "/queryNotBindedEquimentList.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap queryNotBindedEquimentList(String uuid)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			resultMap.put(CommonContans.STRUTS_DATA,
					crossingService.queryNotBindedEquimentList(uuid));
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	@RequestMapping(value = "/stationAssignCrossion.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap stationAssignCrossion(
			@RequestBody List<CrossingToStation> list)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			crossingService.stationAssignCrossion(list);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	@RequestMapping(value = "/stationAndCrossion.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap stationAndCrossion(@RequestBody StationAndCrossionVo scvo)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			crossingService.stationAndCrossion(scvo);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	
	@RequestMapping(value = "/crossionAssignEquipment.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap crossionAssignEquipment(
			@RequestBody List<CrossingToEquipment> list)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			crossingService.crossionAssignEquipment(list);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
}
